package fl.android;

import fl.android.ui.UIRenderer;
import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.Window;
import android.view.WindowManager;

public class FLAndroidActivity extends Activity {

	private UIRenderer ui;
	private GLSurfaceView gl;

	public static FLAndroidActivity activity;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Project.notes.clear();
		activity = this;
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		gl = new GLSurfaceView(this);
		ui = new UIRenderer();
		gl.setRenderer(ui);
		setContentView(gl);
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
			ui.touch((int) event.getX() - gl.getLeft(), gl.getBottom()
					- (int) event.getY() + gl.getTop());
		}
		return super.onTouchEvent(event);
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		return true;
	}
}